import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import VueSetupExtend from 'vite-plugin-vue-setup-extend';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
export default defineConfig({
	base: '',
	 server: {
		host: '0.0.0.0', //ip地址
    port: 3000, //端口号
    open: true ,//启动后是否自动打开浏览器,
    proxy: {
      '/api': {
        target: 'http://localhost:3001',
        changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  },
	plugins: [
		vue(),
		VueSetupExtend(),
		AutoImport({
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [ElementPlusResolver()]
		})
	],
	 
	optimizeDeps: {
		include: ['schart.js']
	},
	css: {
    preprocessorOptions: {
      less: {
        // 配置 Less 的选项，例如修改变量等
        javascriptEnabled: true, // 为了使用 JavaScript 表达式，例如 `@{var}`
        additionalData: `@import "@/assets/less/variables.less";`, // 全局导入变量等
      },
    },
  },
	resolve: {
		alias: {
			'@': '/src',
			'~': '/src/assets'
		}
	},
	define: {
		__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: "true",
	},
});
